*******************************************************************
*Replication code for
*	Article: COVID 19 infection induces higher trust in strangers
*	Journal: PNAS
*	Authors: Diego Gambetta and Davide Morisi
*******************************************************************

*PANEL ANALYSIS

*Set working directory
cd "[your working directory]"

*open data in long format
use "Replication\Data\swg_panel_long.dta", clear

xtset TEL_numeric wave

*controls
global demo_basic "i.female age ib2.edu4 i.area i.group"
global demo_panel "i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.meanperceived2_eco01 i.area i.group"
global demo_basic_region "i.female age ib2.edu4 i.region2 i.group"
global demo_panel_region "i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.meanperceived2_eco01 i.region2 i.group"

*municipality controls
global demo_geo "log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec"

*suffering from covid
*1= suffered once, 2=suffered twice, 3=suffered each time
fre meancovid meancovidr if panel==4


******************

*Table C1. Panel data analysis (within-between random effects model)
eststo clear
*1. basic control
eststo clear
eststo model1: xtreg trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_basic if panel==4, re
*standardized
xtreg st_trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_basic if panel==4, re
eststo st_model1: margins, dydx(covid_diff meancovidr) post

*2. full model
eststo model2: xtreg trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
*standardized
xtreg st_trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_model2: margins, dydx(covid_diff meancovidr) post

*table
esttab model1 model2 using "~TableC1.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C1. Panel data analysis") wide compress noeqlines replace
*standardized DVs
esttab st_model1 st_model2 using "~TableC1st.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C1. Panel data analysis") wide compress noeqlines replace

*
*Table C1. confirmed symptoms
eststo clear
*1. basic control
eststo clear
xtreg trust_strangerW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_basic if panel==4, re
eststo model1conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_trust_strangerW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_basic if panel==4, re
eststo st_model1conf: margins, dydx(covid_conf_diff meancovid_confr) post

*2. full model
xtreg trust_strangerW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo model2conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_trust_strangerW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_model2conf: margins, dydx(covid_conf_diff meancovid_confr) post

*table
esttab model1conf st_model1conf model2conf st_model2conf using "~TableC1conf.rtf", ///
mtitles("model 1" "model 1 (st dv)" "model 2" "model 2 (st dv)")  ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C1. Panel data analysis") wide compress noeqlines replace


***************
*Figure 2. Effect of individual changes in COVID-19 symptoms on interpersonal trust
eststo clear

*trust in strangers
*all people
clonevar covid_diff_graph = covid_diff
xtreg trust_strangerW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marA: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*confirmed
clonevar covid_diff_graph = covid_conf_diff
xtreg trust_strangerW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marB: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*graph
coefplot marA marB, vert yline(0, lpattern(dash) lcolor(gs10)) graphregion(color(white)) ///
legend(off) title("Trust in strangers") ///
xtitle("Change in COVID-19 symptoms (within individuals)") xlabel("") ///
ytitle("Change in trust over time") name(fig2A, replace) level(90 95)

*trust in neighbors
*all people
clonevar covid_diff_graph = covid_diff
xtreg trust_neighbourW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marC: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*confirmed
clonevar covid_diff_graph = covid_conf_diff
xtreg trust_neighbourW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marD: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*graph
coefplot marC marD, vert yline(0, lpattern(dash) lcolor(gs10)) graphregion(color(white)) ///
legend(off) title("Trust in neighbors") ///
xtitle("Change in COVID-19 symptoms (within individuals)") xlabel("") ///
ytitle("") name(fig2B, replace) level(90 95)

*trust in police
*all people
clonevar covid_diff_graph = covid_diff
xtreg trust_policeW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marE: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*confirmed
clonevar covid_diff_graph = covid_conf_diff
xtreg trust_policeW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marF: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*graph
coefplot marE marF, vert yline(0, lpattern(dash) lcolor(gs10)) graphregion(color(white)) ///
legend(off) title("Trust in police") ///
xtitle("Change in COVID-19 symptoms (within individuals)") xlabel("") ///
ytitle("") name(fig2C, replace) level(90 95)

*generalized trust
*all people
clonevar covid_diff_graph = covid_diff
xtlogit trust_genW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marG: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*confirmed
clonevar covid_diff_graph = covid_conf_diff
xtlogit trust_genW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marH: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*graph
coefplot marG marH, vert yline(0, lpattern(dash) lcolor(gs10)) graphregion(color(white)) ///
legend(off) title("Generalized trust") ///
xtitle("Change in COVID-19 symptoms (within individuals)") xlabel("") ///
ytitle("") name(fig2D, replace) level(90 95)

*trust in Italians
*all people
clonevar covid_diff_graph = covid_diff
xtreg trust_itW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marI: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*confirmed
clonevar covid_diff_graph = covid_conf_diff
xtreg trust_itW covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marL: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*graph
coefplot marI marL, vert yline(0, lpattern(dash) lcolor(gs10)) graphregion(color(white)) ///
legend(off) title("Trust in Italians""(Waves 2 & 3)") ///
xtitle("Change in COVID-19 symptoms (within individuals)") xlabel("") ///
ytitle("") name(fig2E, replace) level(90 95)

*pca
fre npca_full1_W // pca with trust in italians, w2 and 3
*all people
clonevar covid_diff_graph = covid_diff
xtreg npca_full1_W covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marJ: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*confirmed
clonevar covid_diff_graph = covid_conf_diff
xtreg npca_full1_W covid_diff_graph covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo marK: margins, dydx(covid_diff_graph) post
drop covid_diff_graph
*graph
coefplot marJ marK, vert yline(0, lpattern(dash) lcolor(gs10)) graphregion(color(white)) ///
legend(off) title("PCA all items""(Waves 2 & 3)") ///
xtitle("Change in COVID-19 symptoms (within individuals)") xlabel("") ///
ytitle("") name(fig2F, replace) level(90 95)

*final figure
graph combine fig2A fig2B fig2C fig2D fig2E fig2F, graphregion(color(white)) 
xtitle("change in COVID-19 exposure (panel data)")


*****************

*
*Table C2. Panel data analysis of trust in stranger – additional models
gen risk01 = w2_risk_genr/10
eststo clear
*1. basic control
eststo model1: xtreg trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
c.risk01 lr_int5 $demo_basic_region if panel==4, re
*standardized
xtreg st_trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
c.risk01 lr_int5 $demo_basic_region if panel==4, re
eststo st_model1: margins, dydx(covid_diff meancovidr)

*2. full model
eststo model2: xtreg trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
c. risk01 lr_int5 $demo_panel_region $demo_geo if panel==4, re
*standardized
xtreg st_trust_strangerW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
c. risk01 lr_int5 $demo_panel_region $demo_geo if panel==4, re
eststo st_model2: margins, dydx(covid_diff meancovidr)

*table
esttab model1 model2 using "~TableC2.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C2. Panel data additional models") wide compress noeqlines replace
*standardized DV
esttab st_model1 st_model2 using "~TableC2st.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C2. Panel data additional models") wide compress noeqlines replace


***********
*Table C3. Panel data analysis with additional measures of trust
eststo clear

*1. Trust in neighbours
eststo trust_neigh: xtreg trust_neighbourW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
*standardized
xtreg st_trust_neighbourW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_trust_neigh: margins, dydx(covid_diff meancovidr) post

*2. Trust in police
eststo trust_poli: xtreg trust_policeW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
*standardized
xtreg st_trust_policeW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_trust_poli: margins, dydx(covid_diff meancovidr) post

*3. Trust gen
eststo trust_gen: xtlogit trust_genW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
margins, dydx(meancovidr)

*4. Trust in Italians
eststo trust_it: xtreg trust_itW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
*standardized
xtreg st_trust_itW covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_trust_it: margins, dydx(covid_diff meancovidr) post

*Table
esttab trust_neigh trust_poli trust_gen trust_it using "~TableC3.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C3. Panel data analysis with additional measures of trust") compress noeqlines replace
*standardized DVs
esttab st_trust_neigh st_trust_poli st_trust_it using "~TableC3st.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C3. Panel data analysis with additional measures of trust") compress noeqlines replace


*Table C3. confirmed symptoms only
eststo clear
*1. Trust in neighbours
xtreg trust_neighbourW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo trust_neigh_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_trust_neighbourW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_trust_neigh_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*2. Trust in police
xtreg trust_policeW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo trust_poli_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_trust_policeW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_trust_poli_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*3. Trust gen
xtlogit trust_genW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo trust_gen_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*4. Trust in Italians
xtreg trust_itW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo trust_it_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_trust_itW covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_trust_it_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*Table
esttab trust_neigh_conf st_trust_neigh_conf trust_poli_conf st_trust_poli_conf trust_it_conf st_trust_it_conf using "~TableC3conf.rtf", ///
mtitles("trust neigh" "trust neigh (st dv)" "trust police" "trust neigh (st dv)" "trust it" "trust it (st dv)")  ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C3. COnfirmed covid-19 symptoms only") compress noeqlines replace



**********
*Table C4. Panel data analysis with additional measures of trust (principal component analysis)

eststo clear
*1. PCA, first component, all waves
eststo pca1: xtreg npca1_W covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
*standardized
xtreg st_pca1_W covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_pca1: margins, dydx(covid_diff meancovidr) post

*2. Pca with trust in italians, waves 2 and 3
eststo pca_full: xtreg npca_full1_W covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
*standardized
xtreg st_pca_full1_W covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovidr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_pca_full: margins, dydx(covid_diff meancovidr) post

*Table
esttab pca1 pca_full using "~TableC4A.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C4. Panel data analysis PCA") compress noeqlines replace
*standardized DVs
esttab st_pca1 st_pca_full using "~TableC4st.rtf", ///
mtitles("pca1 (st dv)" "pca full (st dv)" "pca partial (st dv)")  ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C4. Panel data analysis PCA") compress noeqlines replace


*Table C4. Confirmed symptoms only
eststo clear
*1. PCA, first component, all waves
xtreg npca1_W covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo pca1_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_pca1_W covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_pca1_conf: margins, dydx(covid_conf_diff meancovid_confr) post

*2. Pca with trust in italians, waves 2 and 3
xtreg npca_full1_W covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo pca_full_conf: margins, dydx(covid_conf_diff meancovid_confr) post
*standardized
xtreg st_pca_full1_W covid_conf_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_confr meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
$demo_panel $demo_geo if panel==4, re
eststo st_pca_full_conf: margins, dydx(covid_conf_diff meancovid_confr) post

*Table
esttab pca1_conf st_pca1_conf pca_full_conf st_pca_full_conf using "~TableC4conf.rtf", ///
mtitles("pca1 conf" "pca1 conf (st dv)" "pca full " "pca full conf (st dv)")  ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Table C4. Confirmed symptoms only") compress noeqlines replace


*********************
*MECHANISMS
*********************

*
*Table C6. Mechanisms, basic controls
eststo clear
*1. Family
fre w2_family_filter
eststo: xtreg trust_strangerW i.meancovid01##i.w2_family_filter ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.area i.group if panel==4, re
*2. Live alone
fre meanlive_alone01
eststo: xtreg trust_strangerW i.meancovid01##i.meanlive_alone01 ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.area i.group if panel==4, re
*3. Economic condition
fre meanperceived2_eco01
eststo: xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01 ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.area i.group if panel==4, re
*4. Help
fre meanhelp_by_volstr
eststo: xtreg trust_strangerW i.meancovid01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.area i.group if panel==4, re
*table
esttab using "~tableC6_basic.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Mechanisms - basic models") compress noeqlines replace


*
*Table C7 Full controls
eststo clear
*1. Family
fre w2_family_filter
eststo: xtreg trust_strangerW i.meancovid01##i.w2_family_filter ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
$demo_geo if panel==4, re
*2. Live alone
fre meanlive_alone01
eststo: xtreg trust_strangerW i.meancovid01##i.meanlive_alone01 ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
$demo_geo if panel==4, re
*3. Economic condition
fre meanperceived2_eco01
eststo: xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01 ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.area i.group ///
$demo_geo if panel==4, re
*4. Help
fre meanhelp_by_volstr
eststo: xtreg trust_strangerW i.meancovid01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
$demo_geo if panel==4, re
*table
esttab using "~tableC7_full.rtf", ///
b(%6.3f) se(%6.3f) starlevels(+ .1 * .05 ** .01 *** .001)  scalars (r2) title("Mechanisms - full models") compress noeqlines replace


**************
*Figure 4. Testing mechanisms (panel data, interaction models)

*Same models in Table C7

*A. Family
fre w2_family_filter
recode w2_family_filter (0=1 "No") (1=0 "Yes"), gen(w2_family_filterrev)
xtreg trust_strangerW i.meancovid01##i.w2_family_filterrev ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
$demo_geo if panel==4, re
*margin
margins w2_family_filterrev, dydx(meancovid01) post
coefplot, vert yline(0, lpattern(dash) lcolor(gray)) title("...having family") level(90 95) ///
yscale(range(-.1(.05).25)) ylabel(-.1(.05).25) ///
ytitle("Trust in strangers (wallet question, from 0 to 1)") graphregion(color(white)) name(family, replace)
*B. live alone
xtreg trust_strangerW i.meancovid01##i.meanlive_alone01 ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
$demo_geo if panel==4, re
*margins
margins meanlive_alone01, dydx(meancovid01) post
coefplot, vert yline(0, lpattern(dash) lcolor(gray)) title("...living alone") level(90 95) ///
text(.24 2 "*", color(gs4) orientation(horizontal) placement(6)) ///
yscale(range(-.1(.05).25)) ylabel(-.1(.05).25) ///
ytitle("") graphregion(color(white)) name(live_alone, replace)
*C. eco
xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01 ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.area i.group ///
$demo_geo if panel==4, re
*margins
margins meanperceived2_eco01, dydx(meancovid01) post
coefplot, vert yline(0, lpattern(dash) lcolor(gray)) title("...economic condition") level(90 95)  ///
text(.15 2 "*", color(gs4) orientation(horizontal) placement(6)) ///
yscale(range(-.1(.05).25)) ylabel(-.1(.05).25) ///
ytitle("") graphregion(color(white)) name(economy, replace)	
*D. help
label de yes_no 0"No" 1"Yes", modify
label val meanhelp_by_volstr yes_no
xtreg trust_strangerW i.meancovid01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 i.meanlive_alone01 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
$demo_geo if panel==4, re
*margins
margins meanhelp_by_volstr, dydx(meancovid01) post
coefplot, vert yline(0, lpattern(dash) lcolor(gray)) title("...receiving help") level(90 95) ///
text(.19 2 "+", color(gs4) orientation(horizontal) placement(6)) ///
yscale(range(-.1(.05).25)) ylabel(-.1(.05).25) ///
ytitle("") graphregion(color(white)) name(help, replace)	

*final figure combined
graph combine family live_alone economy help, title("Effect of individual exposure to COVID-19 by...") graphregion(color(white))



***********
*Figure C1 TRIPLE INTERACTIONS

*TRIPLE INTERACTION - LIVE ALONE AND RECEIVE HELP

*Effects of having (vs. not having) covid within each category
xtreg trust_strangerW i.meancovid01##i.meanlive_alone01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
*no help > covid has no effect among those who don't live alone, but it does affect trust among those who live alone
margins meanlive_alone01,dydx(meancovid01) at(meanhelp_by_volstr==0)
*help > covid has an effect among those who don't live alone. the effect is large but not sign among those who live alone
margins meanlive_alone01,dydx(meancovid01) at(meanhelp_by_volstr==1)

*Figure
eststo clear
*not helped - no covid
xtreg trust_strangerW i.meancovid01##i.meanlive_alone01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo no_covid_symptoms: margins meanlive_alone01, at(meancovid01==0 meanhelp_by_volstr==0) post // no symptoms
*not helped - covid
xtreg trust_strangerW i.meancovid01##i.meanlive_alone01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo covid_symptoms: margins meanlive_alone01, at(meancovid01==1 meanhelp_by_volstr==0) post // symptoms
*graph
coefplot no_covid_symptoms covid_symptoms, vert graphregion(color(white)) title("Did not receive help") ///
ytitle("Average level of trust in strangers") xlabel(1 "Did not live alone" 2 "Live alone") name(no_help, replace) ///
yscale(range(.35(.05).7)) ylabel(.35(.05).7) level(90) ///
text(.6 2.15 "*", color(gs2) orientation(horizontal) placement(2))

eststo clear
*helped - no covid
xtreg trust_strangerW i.meancovid01##i.meanlive_alone01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo no_covid_symptoms: margins meanlive_alone01, at(meancovid01==0 meanhelp_by_volstr==1) post // no symptoms
*helped - covid
xtreg trust_strangerW i.meancovid01##i.meanlive_alone01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanperceived2_eco01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo covid_symptoms: margins meanlive_alone01, at(meancovid01==1 meanhelp_by_volstr==1) post // symptoms
*graph
coefplot no_covid_symptoms covid_symptoms, vert graphregion(color(white)) title("Received help") ///
ytitle("") xlabel(1 "Did not live alone" 2 "Live alone") name(help, replace) ///
yscale(range(.35(.05).7)) ylabel(.35(.05).7) level(90) ///
text(.58 1.15 "*", color(gs2) orientation(horizontal) placement(2))

*COMBINED
graph combine no_help help, graphregion(color(white)) name(triple_alone)

*
*TRIPLE INTERACTION - economic condition AND RECEIVE HELP
fre meanperceived2_eco01

*Effects of having (vs. not having) covid within each category
xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanlive_alone01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
*no help > covid has no effect regardless of eco condition
margins meanperceived2_eco01,dydx(meancovid01) at(meanhelp_by_volstr==0)
*help > covid increses trust among those in bad eco condition
margins meanperceived2_eco01,dydx(meancovid01) at(meanhelp_by_volstr==1)

eststo clear
*not helped - no covid
xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanlive_alone01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo no_covid_symptoms: margins meanperceived2_eco01, at(meancovid01==0 meanhelp_by_volstr==0) post
*not helped - covid
xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanlive_alone01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo covid_symptoms: margins meanperceived2_eco01, at(meancovid01==1 meanhelp_by_volstr==0) post 
*graph
coefplot no_covid_symptoms covid_symptoms, vert graphregion(color(white)) title("Did not receive help") ///
ytitle("Average level of trust in strangers") xlabel(1 "Good economic condition" 2 "Not good condition") name(eco_no_help, replace) ///
yscale(range(.35(.05).65)) ylabel(.35(.05).65) level(90)

eststo clear
*helped - no covid
xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanlive_alone01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo no_covid_symptoms: margins meanperceived2_eco01, at(meancovid01==0 meanhelp_by_volstr==1) post 
*helped - covid
xtreg trust_strangerW i.meancovid01##i.meanperceived2_eco01##i.meanhelp_by_volstr i.w2_help_by_volstrpre ///
covid_diff covid_fam4diff covid_fr4diff covid_col4diff excess_w5_diff01a ///
meancovid_family4 meancovid_friends4 meancovid_col4 meanexcess_w501 ///
i.female age ib2.edu4 ib2.employ1 i.meanlive_alone01 i.area i.group ///
log_pop2018 log_dens2018 male_ratio_dec share65plus_dec employ_rate2018_dec if panel==4, re
eststo covid_symptoms: margins meanperceived2_eco01, at(meancovid01==1 meanhelp_by_volstr==1) post 
*graph
coefplot no_covid_symptoms covid_symptoms, vert graphregion(color(white)) title("Received help") ///
ytitle("") xlabel(1 "Good economic condition" 2 "Not good condition") name(eco_help, replace) ///
yscale(range(.35(.05).65)) ylabel(.35(.05).65) level(90) ///
text(.58 2.15 "*", color(gs2) orientation(horizontal) placement(2))

*COMBINED
graph combine eco_no_help eco_help, graphregion(color(white)) name(triple_eco)

*FINAL
graph combine triple_alone triple_eco, graphregion(color(white)) name(triple_int)



